import axios from 'axios';

function convertToArray(nodes) {
  var array = null;
  try {
    array = Array.prototype.slice.call(nodes, 0);
  } catch (ex) {
    array = [];
    for (var i = 0; i < nodes.length; i++) {
      array.push(nodes[0]);
    }
  }
  return array;
}
document.addEventListener('DOMContentLoaded', function() {
  console.clear();
  setTimeout(() => {
    var list = document.querySelectorAll('.layers_item');
    let result = convertToArray(list).map(t => t.textContent);
    console.log('result', result);
    axios.get('https://alipic.lanhuapp.com/SketchJSON05838fd7db3ac69cac05e314e77b7b3997ec51c1d0a7c84c03b64a705ae00fda').then(res => {
      let data = res.data.info.filter(t => t.type !== 'layer-group').map(t => t.name); // 161顶部导航背景
      console.log('res', data);
      let arr = [];
      result.forEach((el, index) => {
        arr.push(el + ',' + data[index]);
      });
      console.log(arr);
    });
  }, 3000);
});
